package com.example.experminent3;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.List;
import java.util.Map;

public class ActionModeAdapter extends BaseAdapter {
    private Context context;
    private List<Map<String, Object>> dataList;

    public ActionModeAdapter(Context context, List<Map<String, Object>> dataList) {
        this.context = context;
        this.dataList = dataList;
    }

    @Override
    public int getCount() {
        return dataList.size();
    }

    @Override
    public Object getItem(int position) {
        return dataList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.item_action_mode, parent, false);
        }
        ImageView ivIcon = convertView.findViewById(R.id.iv_icon);
        TextView tvText = convertView.findViewById(R.id.tv_text);

        Map<String, Object> item = dataList.get(position);
        ivIcon.setImageResource((Integer) item.get("icon"));
        tvText.setText((String) item.get("text"));

        return convertView;
    }
}